{% extends 'app01/backend.html' %}
{% block article %}
    <h3 class="text-center">修改文章</h3>
    {#    利用form表单提交数据#}
    <form action="{% url 'app01_editor_article' %}" method="post">
        {% csrf_token %}
        <p>标题</p>
        <div>
            <input type="text" name="title" class="form-control" id="title" value="{{ article.title }}">
        </div>
        <p>内容</p>
        <div><textarea name="content" id="id_content01" rows="15" cols="100" class="form-control"  >{{ article.content|safe }}</textarea></div>
        <p><b>分类</b></p>
        <div>

            {% for category in category_obj %}
                {% if category_name.article__category__name == category.name %}
                     {{ category.name }}<input type="radio" name="category" value="{{ category.pk }}" class="radio_c" checked>
                {% else %}
                     {{ category.name }}<input type="radio" name="category" value="{{ category.pk }}" class="radio_c">
                {% endif %}

            {% endfor %}

        </div>
        <hr>
        <p><b>标签</b></p>

        <div>
            {% for tag in tag_obj %}
               {% for one_id  in tag_lis %}
                   {% if tag.pk == one_id %}
                       {{ tag.name }}<input type="checkbox" name="tag" value="{{ tag.pk }}" class="checkbox_c" checked>
                   {% endif %}
               {% endfor %}

                {% if tag.id not in tag_lis %}
                    {{ tag.name }}<input type="checkbox" name="tag" value="{{ tag.pk }}" class="checkbox_c">

                {% endif %}

            {% endfor %}

            <a href="/app01/backend/" class="btn btn-danger btn-sm pull-right">返回文章列表</a>
        </div>
        <hr>
        <button class="btn btn-block btn-primary" id="submit_id">提交</button>
        <hr>
        <!--将get请求获取的文章的id，保存到这里，到时候随post请求发送给后端-->
        <input type="text" value="{{ article_id }}" name="article_id" hidden>
    </form>
{% endblock %}




{% block js %}

    {% load static %}
    <script charset = "utf-8" src = "{% static 'kindeditor/kindeditor-all.js' %}" ></script>
<script>
    KindEditor.ready(function (K) {

        window.editor = K.create('#id_content01',{
            height:'500px',
             uploadJson : '/app01/upload/img/',//上传图片的后端的提交路径，由专门的视图函数来处理
            extraFileUploadParams : {//上传文件需要额外的参数,csrf的token
               'csrfmiddlewaretoken':'{{ csrf_token }}'},
        });

    })

</script>



{% endblock %}
